package com.magicborrow.views;

import android.app.Dialog;
import android.content.Context;
import android.content.Intent;
import android.graphics.drawable.Icon;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;

import com.magicborrow.MagicBorrowApplication;
import com.magicborrow.R;
import com.magicborrow.activity.MainActivity;
import com.magicborrow.utils.ViewPressedUtil;

/**
 * Created by ghost on 16/4/28.
 */
public class SuccessDialog extends Dialog {
    private String title;

    private int iconId;

    public SuccessDialog(Context context, String title, int iconId) {
        super(context, R.style.msgDialog);
        this.title = title;
        this.iconId = iconId;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.sucess_dailog);
        setCanceledOnTouchOutside(true);
        TextView tv = ((TextView) findViewById(R.id.tv_title));
        tv.setText(title);
        tv.setCompoundDrawablesWithIntrinsicBounds(getContext().getResources().getDrawable(iconId), null, null, null);
        findViewById(R.id.tv_continue).setOnTouchListener(ViewPressedUtil.TouchPress);
        findViewById(R.id.tv_continue).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                Intent intent = new Intent(getContext(), MainActivity.class);
                getContext().startActivity(intent);
                MagicBorrowApplication.getInstance().getMainActivty().toFindActivity();
            }
        });
       /* if (okListener != null)
            findViewById(R.id.tv_ok).setOnClickListener(okListener);*/
    }


    public void setOnViewPostsClick(View.OnClickListener listener) {
        findViewById(R.id.tv_view_posts).setOnClickListener(listener);
        findViewById(R.id.tv_view_posts).setOnTouchListener(ViewPressedUtil.TouchPress);
    }


}
